ImapFolderAgent: Unstringify integer keys of a hash saved in JSON.

Akinori MUSHA 10 years ago
parent
commit
c1b9caa8cc
2 changed files with 7 additions and 2 deletions
  1. 6 1
      app/models/agents/imap_folder_agent.rb
  2. 1 1
      spec/models/agents/imap_folder_agent_spec.rb

+ 6 - 1
app/models/agents/imap_folder_agent.rb

@@ -420,7 +420,12 @@ module Agents
420 420
     class Seen < Hash
421 421
       def initialize(hash = nil)
422 422
         super()
423
-        update(hash) if hash
423
+        if hash
424
+          # Deserialize a JSON hash which keys are strings
425
+          hash.each { |uidvalidity, uid|
426
+            self[uidvalidity.to_i] = uid
427
+          }
428
+        end
424 429
       end
425 430
 
426 431
       def []=(uidvalidity, uid)

+ 1 - 1
spec/models/agents/imap_folder_agent_spec.rb

@@ -24,7 +24,7 @@ describe Agents::ImapFolderAgent do
24 24
         end
25 25
 
26 26
         def uidvalidity
27
-          '100'
27
+          100
28 28
         end
29 29
 
30 30
         def has_attachment?